package org.cinvestav.computacion.matias.onlyangel.grafo;

import java.util.ArrayList;

public class HiloController {
	public Matriz m = new Matriz();
	public ArrayList<Integer> xa = new ArrayList<Integer>(), ya = new ArrayList<Integer>();
	public ArrayList<Hilo> hilos = new ArrayList<Hilo>();
	public int x0,y0,wid,hei;
	
	public int alcanzado;
	
	public HiloController(int w, int h, int x, int y){
		m.init(h, w);
		m.initRandom();
		m.print();
		x0 = x;
		y0 = y;
		hei =h;
		wid = w;
		
		alcanzado = 0;
	}
	public void addDestino(int x, int y){
		hilos.add(new Hilo(m, wid, hei, x0, y0, x, y, this));
	}
	
	public synchronized void finalizado(){
		alcanzado++;
	}
	
	public synchronized boolean continua(){
		if (alcanzado<3)
			return true;
		else
			return false;
	}
	
	public static void main(String[] args) {
		HiloController hc = new HiloController(17, 21, 10, 10);
		hc.addDestino(4,3);
		hc.addDestino(10, 8);
		hc.addDestino(10,10);
		hc.addDestino(15,15);
		//hc.addDestino(7,16);
		hc.run();
	}
	private void run() {
		for (int n=0; n<hilos.size();n++){
			hilos.get(n).start();
		}
		
	}
}
